package com.wl.shixun1.mymvc;

public class DoNum {

    public static Num fun(String number){
        Num result;
        int i;
        i=number.indexOf("/");

        if(i!=-1){
            result=new Fraction();
            ((Fraction) result).setF1(Integer.parseInt(number.substring(0,i)));
            ((Fraction) result).setF2(Integer.parseInt(number.substring(i+1)));
        }
        else if(number.contains(".")) {
            result=new MyDecimal(number);
        }
        else {
            result=new MyInt();
            ((MyInt) result).setF(Integer.parseInt(number));
        }
        return result;
    }

}